#pragma once
#include <QFrame>
#include <qbprotocol/include/SSQBModel.h>
#include <map>
#include <string>

class DetailData;
class STabCtrl;
class SVirtualTable;
class SComboBox;
class STableColumnSet;
class QTimer;

class BestBidOfr : public QWidget
{
	Q_OBJECT
	enum eQuoteType { emCleanPrice = 0, emFullPrice, emOther };
public:
	BestBidOfr(QWidget* p);
protected:
	void paintEvent(QPaintEvent* event) override;

public slots :
	void onBrokerBestQuoteChanged(xQBBestPriceSynthetical_Unit_c, xQBBestPriceSynthetical_Unit_c, bool);//5家最优
	void onTimeout();
private:
    QString		m_bidValue, m_bidVolume;
    QString		m_ofrValue, m_ofrVolume;
	int			m_bidType = emCleanPrice;
	int			m_ofrType = emCleanPrice;
	int			m_bidFlashCount = 0;
	int			m_ofrFlashCount = 0;
	QTimer*		m_timer;
};

class BrokerBestPrice : public QFrame
{
	Q_OBJECT
public:
	BrokerBestPrice(QWidget* p, QSharedPointer<DetailData> data);
	void update(int nBrokerId);
	bool isShowTab();

protected:
	void paintEvent(QPaintEvent* event) override;

protected slots:
	void onBrokerTabSelectChanged(int index);
	void onClearSpeedChanged(int index);
	void onBestPriceChanged(std::map<std::string, int>);
	void updateList();

private:
	void initBestPriceList();

private:
	QSharedPointer<DetailData> m_data = nullptr;
	BestBidOfr* m_bestBidOfr = nullptr;
    STabCtrl* m_brokerTab = nullptr;
	SVirtualTable* m_bestTable = nullptr;
	SComboBox* m_cbClearSpeed = nullptr;
	STableColumnSet* m_tableSet = nullptr;
	int		m_clearSpeed = 0;
	int		m_brokerId = -1;

	bool	m_showAll = false; //显示5家最优
	bool	m_showTab = false; //显示中介tab
	bool	m_showAllTable = false; //显示5家报价的table
};